package com.pan.server.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@Slf4j
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket docket() {
        // 接口文档基本信息

        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("电商平台接口文档")
                .version("2.0")
                .description("电商平台接口文档")
                .build();
        // 创建docket对象
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                // 配置基本信息
                .apiInfo(apiInfo)
                // 指定要扫描的包
                .select()
                // 指定要扫描的包
                .apis(RequestHandlerSelectors.basePackage("com.pan.server.controller"))
                // 扫描所有
                .paths(PathSelectors.any())
                // 执行
                .build();
        return docket;
    }

}